/**
 * 
 */
package com.honghao.student.hashandequals;

import java.util.Collections;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.Set;
/**
 * @author honghao.li
 *
 */
public class HashAndEquals {
    
    public static void main(String[] args) {
        test1();
    }
    
    /**
     * 不覆盖equals方法
     * equals方法都是调用Object类的equals方法，而Object的equals方法主要用于判断对象的内存地址引用是不是同一个地址（是不是同一个对象）
     */
    public static void test1(){
        
        LinkedList<Student> list = new LinkedList<Student>();  
        Set<Student> set = new HashSet<Student>();  
        Student stu1  = new Student(3,"张三");  
        Student stu2  = new Student(3,"张三");  
        System.out.println("stu1 == stu2 : "+(stu1 == stu2));  
        System.out.println("stu1.equals(stu2) : "+stu1.equals(stu2));  
        list.add(stu1);  
        list.add(stu2);  
        System.out.println("list size:"+ list.size());  
          
        set.add(stu1);  
        set.add(stu2);  
        System.out.println("set size:"+ set.size());
        stu1.setAge(34);  
        System.out.println("remove stu1 : "+set.remove(stu1));  
        System.out.println("set size:"+ set.size());  
    }
    
    public void testHashMap(){
        
        Collections.synchronizedMap(null);
        
        //CopyOnWriteArrayList<Student> s = new CopyOnWriteArrayList<>(); 
    }
}
